/*
 *  AbstractNoteTester.cpp
 *  SoundController0002
 *
 *  Created by jiro on 11/10/03.
 *  Copyright 2011 jiro music. All rights reserved.
 *
 */

#include "AbstractNoteTester.h"
#include "../AbstractNote.h"
#include "../ConcreteNote.h"
#include "../../../sc/Tester/CustomAssert.h"

using namespace std;

namespace sc
{
namespace system0039
{
	void AbstractNoteTester::TestAll()
	{
		Test_GetConcreteNotes000();
		Test_GetConcreteNotes001();
		Test_GetConcreteNotes002();
		Test_GetConcreteNotes003();
		Test_GetConcreteNotes004();
	}

	void AbstractNoteTester::Test_GetConcreteNotes000()
	{
		AbstractNote note( Note::D1, Note::E2, Note::mezzoPiano );
		
		std::vector< ConcreteNote > notes;
		note.GetConcreteNotes( notes );
		
		AssertEqual( notes.size(), 2 );

		AssertEqual( notes[ 0 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 0 ].GetNoteMidiNumber( 0 ), Note::E2 );
		AssertEqual( notes[ 0 ].GetNthHarmonics( 1 ), 2 );
		AssertEqual( notes[ 0 ].GetNoteMidiNumber( 1 ), Note::D1 );

		AssertEqual( notes[ 1 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 1 ].GetNoteMidiNumber( 0 ), Note::E2 );
		AssertEqual( notes[ 1 ].GetNthHarmonics( 1 ), 3 );
		AssertEqual( notes[ 1 ].GetNoteMidiNumber( 1 ), Note::D1 );

	}

	void AbstractNoteTester::Test_GetConcreteNotes001()
	{
		AbstractNote note( Note::DSharp1, Note::DSharp3, Note::mezzoPiano );
		
		std::vector< ConcreteNote > notes;
		note.GetConcreteNotes( notes );
		
		AssertEqual( notes.size(), 2 );
		
		AssertEqual( notes[ 0 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 0 ].GetNoteMidiNumber( 0 ), Note::DSharp3 );
		AssertEqual( notes[ 0 ].GetNthHarmonics( 1 ), 3 );
		AssertEqual( notes[ 0 ].GetNoteMidiNumber( 1 ), Note::DSharp1 );

		AssertEqual( notes[ 1 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 1 ].GetNoteMidiNumber( 0 ), Note::DSharp3 );
		AssertEqual( notes[ 1 ].GetNthHarmonics( 1 ), 5 );
		AssertEqual( notes[ 1 ].GetNoteMidiNumber( 1 ), Note::DSharp1 );

	}

	void AbstractNoteTester::Test_GetConcreteNotes002()
	{
		AbstractNote note( Note::D1, Note::D3, Note::mezzoPiano );
		
		std::vector< ConcreteNote > notes;
		note.GetConcreteNotes( notes );
		
		AssertEqual( notes.size(), 2 );
		
		AssertEqual( notes[ 0 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 0 ].GetNoteMidiNumber( 0 ), Note::D3 );
		AssertEqual( notes[ 0 ].GetNthHarmonics( 1 ), 3 );
		AssertEqual( notes[ 0 ].GetNoteMidiNumber( 1 ), Note::D1 );

		AssertEqual( notes[ 1 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 1 ].GetNoteMidiNumber( 0 ), Note::D3 );
		AssertEqual( notes[ 1 ].GetNthHarmonics( 1 ), 5 );
		AssertEqual( notes[ 1 ].GetNoteMidiNumber( 1 ), Note::D1 );
		
	}

	void AbstractNoteTester::Test_GetConcreteNotes003()
	{
		AbstractNote note( Note::D1, Note::B2, Note::mezzoPiano );
		
		std::vector< ConcreteNote > notes;
		note.GetConcreteNotes( notes );
		
		AssertEqual( notes.size(), 2 );
		
		AssertEqual( notes[ 0 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 0 ].GetNoteMidiNumber( 0 ), Note::B2 );
		AssertEqual( notes[ 0 ].GetNthHarmonics( 1 ), 3 );
		AssertEqual( notes[ 0 ].GetNoteMidiNumber( 1 ), Note::D1 );

		AssertEqual( notes[ 1 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 1 ].GetNoteMidiNumber( 0 ), Note::B2 );
		AssertEqual( notes[ 1 ].GetNthHarmonics( 1 ), 4 );
		AssertEqual( notes[ 1 ].GetNoteMidiNumber( 1 ), Note::D1 );
		
	}

	void AbstractNoteTester::Test_GetConcreteNotes004()
	{
		AbstractNote note( Note::D1, Note::FSharp3, Note::mezzoPiano );
		
		std::vector< ConcreteNote > notes;
		note.GetConcreteNotes( notes );
		
		AssertEqual( notes.size(), 3 );
		
		AssertEqual( notes[ 0 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 0 ].GetNoteMidiNumber( 0 ), Note::FSharp3 );
		AssertEqual( notes[ 0 ].GetNthHarmonics( 1 ), 4 );
		AssertEqual( notes[ 0 ].GetNoteMidiNumber( 1 ), Note::D1 );

		AssertEqual( notes[ 1 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 1 ].GetNoteMidiNumber( 0 ), Note::FSharp3 );
		AssertEqual( notes[ 1 ].GetNthHarmonics( 1 ), 5 );
		AssertEqual( notes[ 1 ].GetNoteMidiNumber( 1 ), Note::D1 );

		AssertEqual( notes[ 2 ].GetNthHarmonics( 0 ), 1 );
		AssertEqual( notes[ 2 ].GetNoteMidiNumber( 0 ), Note::FSharp3 );
		AssertEqual( notes[ 2 ].GetNthHarmonics( 1 ), 6 );
		AssertEqual( notes[ 2 ].GetNoteMidiNumber( 1 ), Note::D1 );
	}
	
}
}
